package com.ycxy.school.express.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ycxy.school.express.pojo.dto.OrderAddNewDTO;
import com.ycxy.school.express.service.IFeedbackService;
import com.ycxy.school.express.service.IOrderService;
import com.ycxy.school.express.service.IUserService;
import com.ycxy.school.express.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author jayLuo
 * @Date 2023/1/12 20:25
 * @PackageName:com.ycxy.school.express.controller
 * @ClassName: AdminIndexController
 * @Description: TODO
 * @Version 1.0
 */
@Slf4j
@Api(tags = "00. 仪表盘模块")
@RestController
@RequestMapping("/count")
public class AdminIndexController {

    @Autowired
    private IOrderService orderService;

    @Autowired
    private IFeedbackService feedbackService;

    @Autowired
    private IUserService userService;

    // http://localhost:9080/count/order-wait
    @ApiOperation("查询等待接单的订单数")
    @ApiOperationSupport(order = 100)
    @GetMapping("/order-wait")
    public JsonResult<Integer> countByOrderWait() {
        log.debug("开始处理【查询等待接单的订单数】的请求");
        int num = orderService.countByWait();
        return JsonResult.ok(num);
    }
    // http://localhost:9080/count/order-transport
    @ApiOperation("查询派送中的订单数")
    @ApiOperationSupport(order = 110)
    @GetMapping("/order-transport")
    public JsonResult<Integer> countByOrderTransport() {
        log.debug("开始处理【查询等待接单的订单数】的请求");
        int num = orderService.countByTransport();
        return JsonResult.ok(num);
    }
    // http://localhost:9080/count/order-transport
    @ApiOperation("查询已完成的订单数")
    @ApiOperationSupport(order = 120)
    @GetMapping("/order-complete")
    public JsonResult<Integer> countByOrderComplete() {
        log.debug("开始处理【查询已完成的订单数】的请求");
        int num = orderService.countByComplete();
        return JsonResult.ok(num);
    }


    // http://localhost:9080/count/feedback-wait
    @ApiOperation("查询等待处理的反馈数")
    @ApiOperationSupport(order = 200)
    @GetMapping("/feedback-wait")
    public JsonResult<Integer> countByFeedbackWait() {
        log.debug("开始处理【查询等待处理的反馈数】的请求");
        int num = feedbackService.countByWait();
        return JsonResult.ok(num);
    }
    // http://localhost:9080/count/feedback-process
    @ApiOperation("查询处理中的反馈数")
    @ApiOperationSupport(order = 210)
    @GetMapping("/feedback-process")
    public JsonResult<Integer> countByFeedbackProcess() {
        log.debug("开始处理【查询处理中的反馈数】的请求");
        int num = feedbackService.countByProcess();
        return JsonResult.ok(num);
    }
    // http://localhost:9080/count/feedback-complete
    @ApiOperation("查询处理完成的反馈数")
    @ApiOperationSupport(order = 220)
    @GetMapping("/feedback-complete")
    public JsonResult<Integer> countByFeedbackComplete() {
        log.debug("开始处理【查询处理完成的反馈数】的请求");
        int num = feedbackService.countByComplete();
        return JsonResult.ok(num);
    }

    // http://localhost:9080/count/user
    @ApiOperation("查询所有用户总数量")
    @ApiOperationSupport(order = 300)
    @GetMapping("/user")
    public JsonResult<Integer> countByUser() {
        log.debug("开始处理【查询所有用户总数】的请求");
        int num = userService.count();
        return JsonResult.ok(num);
    }
    // http://localhost:9080/count/user-enable
    @ApiOperation("查询所有已开启的用户总数量")
    @ApiOperationSupport(order = 310)
    @GetMapping("/user-enable")
    public JsonResult<Integer> countByEnable() {
        log.debug("开始处理【查询所有已开启的用户总数】的请求");
        int num = userService.countByEnable();
        return JsonResult.ok(num);
    }
    // http://localhost:9080/count/user-disable
    @ApiOperation("查询所有已禁用的用户总数量")
    @ApiOperationSupport(order = 320)
    @GetMapping("/user-disable")
    public JsonResult<Integer> countByDisable() {
        log.debug("开始处理【查询所有已禁用的用户总数】的请求");
        int num = userService.countByDisable();
        return JsonResult.ok(num);
    }

}
